package com.example.contactinfo;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {

	EditText name;
	EditText phone;
	Spinner months;
	Spinner days;
	Spinner years;
	Button submit;
	Button clear;
	TextView display;
	
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        //variables
        name = (EditText) findViewById(R.id.name_editText);
        phone = (EditText) findViewById(R.id.phone_editText);
        months = (Spinner) findViewById(R.id.months_spinner);
        days = (Spinner) findViewById(R.id.days_spinner);
        years = (Spinner) findViewById(R.id.years_spinner);
        submit = (Button) findViewById(R.id.submit_button);
        clear = (Button) findViewById(R.id.clear_button);
        display = (TextView) findViewById(R.id.display_textView);
        
        //spinners
        
        //months
        ArrayAdapter monthsadapter= ArrayAdapter.createFromResource(this, R.array.months, android.R.layout.simple_spinner_item);
        monthsadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        months.setAdapter(monthsadapter);
        //days
        ArrayAdapter daysadapter= ArrayAdapter.createFromResource(this, R.array.days, android.R.layout.simple_spinner_item);
        daysadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        days.setAdapter(daysadapter);
        //years
        ArrayAdapter yearsadapter= ArrayAdapter.createFromResource(this, R.array.years, android.R.layout.simple_spinner_item);
        yearsadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        years.setAdapter(yearsadapter);
        
        submit.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String tempS = months.getSelectedItem().toString()+days.getSelectedItem().toString()+years.getSelectedItem().toString();
				
				
				
				
				String temp = name.getEditableText().toString()+phone.getEditableText().toString();
				display.setText(temp+tempS);
				
			}
		});
        
        clear.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				months.setSelection(0);
				days.setSelection(0);
				years.setSelection(0);
				//Toast.makeText(MainActivity.this, "PAUL!", Toast.LENGTH_LONG).show();
				String temp = "";
				display.setText(temp);
				
				
			}
		});
        
        
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
}
